var User = require("./userModel.js");

/**
 * [getByConditions description]
 * @Author   zhanggongze
 * @DateTime 2017-05-26
 * @return   {[type]}    [obj]
 */
function getByConditions(){
    var wherestr = {'username' : 'zhanggongze'};
    
    User.find(wherestr, function(err, res){
        if (err) {
            console.log("Error:" + err);
        }
        else {
            console.log("Res:" + res);
        }
    })
}

// getByConditions();

function _getByConditions(){
    var wherestr = {'username' : 'zhanggongze'};
    //输出只会有username字段，设置方法如上，1表示查询输出该字段，0表示不输出
    var opt = {"username": 1 ,"_id": 0};
    
    User.find(wherestr, opt, function(err, res){
        if (err) {
            console.log("Error:" + err);
        }
        else {
            console.log("Res:" + res);
        }
    })
}
_getByConditions();